import sbt._
import sbt.Keys._
import wartremover.WartRemover.autoImport._
import wartremover.Wart

object CodeAnalysis {

  lazy val disable = Seq(
    wartremoverErrors in (Compile, compile) := Seq.empty,
    wartremoverErrors in (Test, compile) := Seq.empty
  )

  lazy val settings = Seq(
    wartremoverErrors in (Compile, compile) := Warts.allBut(disabledWarts: _*),
    wartremoverErrors in (Test, compile) := (wartremoverErrors in (Compile, compile)).value
  )

  private def disabledWarts: List[Wart] =
    List(
      Wart.AsInstanceOf,
      Wart.Any,
      Wart.Equals,
      Wart.ImplicitConversion,
      Wart.ImplicitParameter,
      Wart.JavaSerializable,
      Wart.MutableDataStructures,
      Wart.NonUnitStatements,
      Wart.Nothing,
      Wart.Null,
      Wart.Overloading,
      Wart.OptionPartial, // Generated by boopickle macros
      Wart.Throw,
      Wart.ToString,
      Wart.TraversableOps,
      Wart.Var,
      Wart.While
    )
}
